<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="js/jquery-2.1.1.min.js"></script>
</head>
<body>
	<h1>加湿器状态</h1>
	<form id="humidifierForm" action="device_status.php" Method="POST">   
		 <label for="name">设备地址：</label>
		 <input name="name" type="text" requiredplaceholder="Please enter your name">
		 <label for="opercode">操作码：</label>
		 <input name="opercode" type="text" requiredplaceholder="Please enter operation code">      
		 <button type="submit">读取</button>
	</form>
	<div style="color:#0000FF" id="humidifier_result">
	<h2>读数：</h2>
	</div>

	<h1>尿不湿状态</h1>
	<form id="diaperForm" action="device_status.php" Method="POST">
		 <label for="name">设备地址：</label>
		 <input name="name" type="text" requiredplaceholder="Please enter your name">
		 <label for="opercode">操作码：</label>
		 <input name="opercode" type="text" requiredplaceholder="Please enter operation code">      
		 <button type="submit">读取</button>
	</form>
	<div style="color:#0000FF" id="diaper_result">
	<h2>读数：</h2>
	</div>


	<h1>看视频</h1>

<script>     
$("#humidifierForm").submit(function(event) {         
	/* stop form from submitting normally */        
	 event.preventDefault();
	 /* get some values from elements on the page: */
	 var $form = $(this),
	 $submit = $form.find('button[type="submit"]'),
	 name_value = $form.find('input[name="name"]').val(),
	 opercode_value = $form.find('input[name="opercode"]').val(),
	 url = $form.attr('action');
	 
	 /* Send the data using post */
	 var posting = $.post( url,{
	 	name: name_value,
	 	opercode: opercode_value
	 });

	 posting.done(function( data ) {
	 	/* Put the results in a div */
	 	$("#humidifier_result").html(data);
	 });
});
$("#diaperForm").submit(function(event) {         
	/* stop form from submitting normally */        
	 event.preventDefault();
	 /* get some values from elements on the page: */
	 var $form = $(this),
	 $submit = $form.find('button[type="submit"]'),
	 name_value = $form.find('input[name="name"]').val(),
	 opercode_value = $form.find('input[name="opercode"]').val(),
	 url = $form.attr('action');
	 
	 /* Send the data using post */
	 var posting = $.post( url,{
	 	name: name_value,
	 	opercode: opercode_value
	 });

	 posting.done(function( data ) {
	 	/* Put the results in a div */
	 	$("#diaper_result").html(data);
	 });
});
</script>
</body>
